package com.zb.controller;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zb.Service.DepartmentService;
import com.zb.Service.MoneyService;
import com.zb.Service.TaskService;
import com.zb.Service.UserService;
import com.zb.entity.Money;

@Scope("prototype")
@Component
@RequestMapping("/money")
public class MoneyController {
	@Resource
	private MoneyService ms;
	@Resource
	private UserService us;
	@Resource
	private DepartmentService ds;
	@Resource
	private TaskService ts;
	//添加收入证明
	@RequestMapping(params = "op=add")
	public String addMoney(int userid, int deptid, int roleid, String content,ModelMap modelMap) {
		Money money = new Money();
		money.setUser(us.getUserById(userid));
		money.setDepartment(ds.getDeptById(deptid));
		money.setRole(us.getUserById(roleid));
		money.setContent(content);
		ms.saveMoney(money);
		int maxid = ms.getMaxId();
		ts.saveTask(userid, 7, maxid, roleid);
		modelMap.put("msg", "操作成功！");
		return "money";
	}
}
